package lzk.myshop.config;

import com.qcloud.cos.COSClient;
import com.qcloud.cos.ClientConfig;
import com.qcloud.cos.auth.BasicCOSCredentials;
import com.qcloud.cos.auth.COSCredentials;
import com.qcloud.cos.http.HttpProtocol;
import com.qcloud.cos.region.Region;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Component
public class TencentCloudConfig {
//    @Value("${Tencent.secretId}")
    private String secretId="AKIDCFC2tjBazOfophQ2Vu9ED7tgPBthbYLx";
//    @Value("${Tencent.secretKey}")
    private String secretKey="SehcIUhpmlx5FJG6zqfXJ7udKuLoBadP";
//    @Value("${Tencent.APPID}")
    private String APPID="1320925777";
//    @Value("${Tencent.COS_REGION}")
    private String COS_REGION="ap-nanjing";

    public COSClient get(){

        COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
        Region region = new Region(COS_REGION);
        ClientConfig clientConfig = new ClientConfig(region);
        clientConfig.setHttpProtocol(HttpProtocol.https);
        COSClient cosClient = new COSClient(cred, clientConfig);
        return cosClient;

    }
}
